{% extends "django_book/base.html" %}

{% block content %}
  {% load comments %}

  <h1>Give feedback/comments for your favourite Django book</h1>
  <p><strong>{{ object.name }}</strong> published by <strong>{{ object.publishers }}</strong></p>
  <p><strong>Authors: </strong>
	{% for author in object.authors.all %}
	   {{ author.name }}{% if forloop.last %} {% else %},{% endif %}
        {% endfor %}
  </p>
  <img src='/{{ object.get_image_url }}' alt='{{ object.name }}'>
  {% if object.is_available %} 
    <p>Released on <strong>{{ object.date_of_release|date:"jS F,Y" }}</strong></p>
  {% else %}
    <p>To be released on <strong>{{ object.date_of_release|date:"jS F,Y" }}</strong></p>
  {% endif %}

  {% get_comment_list for django_book.book object.pk as comment_list %}
    {% if comment_list %}
    <h2>Comments</h2>
    {% for comment in comment_list %}
      <h4>{{ comment.name|escape }} at {{ comment.submit_date|date:"r"}}</h4>
      <p>{{ comment.comment|escape|urlizetrunc:"100"|linebreaks }}</p>
      <hr>
    {% endfor %}    
  {% endif %}
  <h2>Leave a comment</h2>
  {% render_comment_form for django_book.book object.pk %}
{% endblock %}

